<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-wechatProductAttribute-edit" th:object="${wechatProductAttribute}">
            <input id="productAttributeId" name="productAttributeId" th:field="*{productAttributeId}"  type="hidden">
            <input name="productCategoryId" type="hidden" id="treeId" th:field="*{productCategoryId}"/>
            <input name="parentId"  type="hidden" id="parentId"/>
			<div class="form-group">	
				<label class="col-sm-3 control-label">商品类别：</label>
				<div class="col-sm-8">
					<div class="input-group">
                    	<input name="productCategoryName" onclick="selectProductCategoryTree()" id="treeName" type="text" placeholder="请选择类目" class="form-control" th:field="*{productCategoryName}"  required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性标题 ：</label>
				<div class="col-sm-8">
					<input id="title" name="title" th:field="*{title}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性全称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" th:field="*{name}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性代码：</label>
				<div class="col-sm-8">
					<input id="code" name="code" th:field="*{code}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性描述 ：</label>
				<div class="col-sm-8">
					<input id="description" name="description" th:field="*{description}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性预设内容：</label>
				<div class="col-sm-8">
					<input id="content" name="content" th:field="*{content}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性默认值：</label>
				<div class="col-sm-8">
					<input id="value" name="value" th:field="*{value}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">排列次序：</label>
				<div class="col-sm-8">
					<input id="orders" name="orders" th:field="*{orders}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<select id="status" name="status"  class="form-control" th:with="type=${@dict.getType('wechat_product_brand_status')}">
					  <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{status}">
					  </option>
					</select>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script th:src="@{/ajax/libs/select/select2.js}"></script>
    <script type="text/javascript">
		var prefix = ctx + "wechat/wechatProductAttribute";
		$("#form-wechatProductAttribute-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});
		/*类目选择*/
        function selectProductCategoryTree() {
        	var treeId = $("#treeId").val();
        	var productCategoryId = $.common.isEmpty(treeId) ? "1" : $("#treeId").val();
			var options = {
				title: '选择类目',
				width: "380",
				url: ctx + "wechat/wechatShopProductCategory/selectChannelTree/" + productCategoryId,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		
        function doSubmit(index, layero){
			var tree = layero.find("iframe")[0].contentWindow.$._tree;
			if ($.tree.notAllowParents(tree)) {
				var body = layer.getChildFrame('body', index);
    			$("#treeId").val(body.find('#treeId').val());
    			$("#treeName").val(body.find('#treeName').val());
    			$("#productCategoryName").val(body.find('#treeName').val());
    			layer.close(index);
			}
		}
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/edit", $('#form-wechatProductAttribute-edit').serialize());
	        }
	    }
	</script>
</body>
</html>
